<!DOCTYPE html>
<html>
<head>
    {include file='public/meta'/}

    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css">
    <link rel="stylesheet" href="__STATIC_URL__/static/css/setcard.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/coupon.css"/>


    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>


    <style>
        .ng-scope input {
            width: 232px;
            margin-left: 5px;
            opacity: 1;
        }
        #img{
            opacity: 0;
        }
        .img {
            width: 375px;
            height: 315px;
            display: inline-block;
            background-size: 100%;
        }
        .fm{
            width: 318px;
            height: 203px;
            display: inline-block;
            background-size: 100%;
        }
        .addcate,.addcdlist{
            height: 34px;
            line-height: 34px;
            border: 1px solid #4cd0ff;
            text-align: center;
            cursor: pointer;
            background-color: #fff;
            display: inline-block;
            color:#4cd0ff;
            margin-right: 8px;
            padding:0 3px;
        }
        @media (min-width: 768px) {
            .modal-dialog {
                width: 600px;
                margin: 200px auto;
            }
        }
        .fllist{
            margin: 10px;
            display: inline-block;
            border: 1px solid #c7c7c7;
            padding: 7PX;
        }
        .glyphicon-remove-circle{
            color: #ff5656;
        }
        .ng-scope input {
            width:70%;
            margin-left: 5px;
            opacity: 1;
        }

        .addcardlist{
            padding:7px 7px;
        }
        .ant-upload-list-item-info {
            background: transparent;
            position: relative;
            width: 120px;
            height: 96px;
            margin: 0 8px 8px 0;
            border-radius: 6px;
            overflow: hidden;
        }
    </style>
</head>
<body>
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">

        <div class="panel mgl15 mgr15">
            <div class="panel-body">
                <!--路径导航-->
                <ol class="breadcrumb">
                    <li>当前位置是&nbsp;:</li>
                    <li>
                        <a href="{:url('cardgifts/cardgiftracklist')}">货架管理</a>
                    </li>
                    <li class="active" style="color: #02b87f;">货架设置</li>
                </ol>
                <div>


                    <div class="panel panel-default ng-scope">
                        <form action="" method="post"  id="formcate">
                            <div class="panel-heading">
                                填写商户号
                            </div>
                            <div class="panel-body">
                                <div class="row">

                                    <div class="col-sm-12">
                                        <div id="myAlert" class="alert alert-success" style="margin:10px 20px;">
                                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                                            <strong>开通支付需要三步操作，填写商户号，绑定小程序AppID，上传代码，请按提示操作！</strong>
                                        </div>
                                        <div id="myAlert3" class="alert alert-success" style="margin:10px 20px;">
                                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                                            <strong>点击开通后，请到微信商户平台后台点击确认！</strong>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">商户号：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">

                                                    <input type="text" name="sub_mch_id" id="sub_mch_id" class="form-control" maxlength="20"  placeholder="请输入商户号" value="" />
                                                </div>
                                            </div>
                                        </div>


                                    </div>
                                </div>

                            </div>
                            <div class="panel-footer">
                            <button class="btn btn-success" type="button" onclick="btn();">开通</button>
                            </div>
                        </form>
                    </div>
                    <div class="panel panel-default ng-scope" id="app" style="display:block">
                        <form action="" method="post"  id="">
                            <div class="panel-heading">
                                绑定小程序APPID
                            </div>
                            <div class="panel-body">
                                <div class="row">

                                    <div class="col-sm-12">
                                        <div id="myAlert2" class="alert alert-success" style="margin:10px 20px;">
                                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                                            <strong>请确认小程序和公众号已关联！</strong>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">商户号：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">

                                                    <input type="text" name="sub_mch_id" id="sub_mch_ids" class="form-control" maxlength="20"  placeholder="请输入商户号" value="" />
                                                </div>
                                            </div>
                                        </div>

                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">绑定小程序APPID：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">

                                                    <input type="text" name="wxa_appid" id="wxa_appid" class="form-control" maxlength="20"  placeholder="请输入小程序APPID" value="" />
                                                </div>
                                            </div>
                                        </div>


                                    </div>
                                </div>

                            </div>
                            <div class="panel-footer">
                                <button class="btn btn-success" type="button" onclick="addbtn();">提交</button>
                            </div>
                        </form>
                    </div>
                    <div class="panel panel-default ng-scope" id="daim" style="display:block">
                        <form action="" method="post"  id="">
                            <div class="panel-heading">
                                上传小程序代码
                            </div>
                            <div class="panel-body">
                                <div class="row">

                                    <div class="col-sm-12">
                                        <div id="myAlert4" class="alert alert-success" style="margin:10px 20px;">
                                            <a href="#" class="close" data-dismiss="alert">&times;</a>
                                            <strong id="fabu"></strong>
                                        </div>
                                        <div class="form-horizontal" data-layout="horizontal">
                                            <div class="form-group">
                                                <label class="col-sm-4 control-label">上传小程序代码：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                                <div class="col-sm-8">
                                                    <button class="btn btn-success" type="button" onclick="wxxiao();">上传小程序代码</button>

                                                </div>
                                            </div>
                                        </div>


                                    </div>
                                </div>

                            </div>
                            <div class="panel-footer">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>







<script>
$(function(){

    $.ajax({
        url: "{:url('cardgifts/getcardrack')}",
        type: "post",
        data: {

        },
        success: function (data) {
            console.log(data);
            if(data.code==0){
            var datas=data.data
                if(parseInt(datas.setup)==1){
                console.log(132132,parseInt(datas.setup))
                    $("#app").attr("style","display:block");
                    $("#sub_mch_id").val(datas.sub_mch_id);
                    $("#sub_mch_ids").val(datas.sub_mch_id);

                }else if(parseInt(datas.setup)==2){
                    $("#app").attr("style","display:block");
                    $("#daim").attr("style","display:block");
                    $("#sub_mch_id").val(datas.sub_mch_id);

                    $("#sub_mch_ids").val(datas.sub_mch_id);
                    $("#wxa_appid").val(datas.wxa_appid);
                }else if(parseInt(datas.setup)==3){
                    $("#app").attr("style","display:block");
                    $("#daim").attr("style","display:block");
                    $("#sub_mch_id").val(datas.sub_mch_id);
                    $("#wxa_appid").val(datas.wxa_appid);
                    $("#sub_mch_ids").val(datas.sub_mch_id);
                    $("#fabu").html("请勿在小程序改变之前发布！")
                }

            }else{

            }
        }
    })
})
</script>
<script>
    function btn(){
        var sub_mch_id=$("#sub_mch_id").val();
        $.ajax({
            url: "{:url('cardgifts/machpaygift')}",
            type: "post",
            data: {
                sub_mch_id:sub_mch_id
            },
            success: function (data) {
                console.log(data);
                if(data.code==0){
                    layer.msg(data.message);
                    $("#sub_mch_ids").val(sub_mch_id);
                    $("#daim").attr("display","block");
                }else{
                    layer.msg(data.message);
                }
            }
        })
    }
    function addbtn(){
        var sub_mch_id=$("#sub_mch_ids").val();
        var wxa_appid=$("#wxa_appid").val();


        $.ajax({
            url: "{:url('cardgifts/bindingmicro')}",
            type: "post",
            data: {
                sub_mch_id:sub_mch_id,
                wxa_appid:wxa_appid
            },
            success: function (data) {
                console.log(data);
                if(data.code==0){
                    layer.msg(data.message);
                    $("#app").attr("display","block")
                }else{
                    layer.msg(data.message);
                }
            }
        })
    }
    function wxxiao(){
        $.ajax({
            url: "{:url('cardgifts/uploadmicrocode')}",
            type: "post",
            data: {

            },
            success: function (data) {
                console.log(data);
                if(data.code==0){
                    layer.msg(data.message);
                    $("#fabu").html("请到小程序后台提交审核并发布！")

                }else{
                    layer.msg(data.message);
                }
            }
        })
    }
</script>
</body>

</html>
